<p class="Paragraph">Expression: Any numeric expression that defines how random numbers will be generated.</p>
<p class="Paragraph">Less than zero: Always returns the same random number.</p>
<p class="Paragraph">Greater than zero: Returns the next random number in the sequence.</p>
<p class="Paragraph">Zero: Returns the random number last generated.</p>
<p class="Paragraph">Omitted: Returns the next random number in the sequence.</p>
<p class="Paragraph">If the same number is passed for each successive call to the Rnd function, the same random-number sequence is generated, because the Expression parameter is used as a starting point for the next number.</p>
<p class="Paragraph">The <span class="T1">Rnd</span> function only returns values ranging from 0 to 1. To generate random integers in a given range, use the formula in the following example:</p>
<p class="P2">Example:</p>
<p class="PropText">Sub ExampleRandomSelect</p>
<p class="PropText">Dim iVar As Integer</p>
<p class="PropText">iVar = Int((15 * Rnd) -2)</p>
<p class="PropText">Select Case iVar</p>
<p class="PropText">Case 1 To 5</p>
<p class="PropText">Print "Number from 1 to 5"</p>
<p class="PropText">Case 6, 7, 8</p>
<p class="PropText">Print "Number from 6 to 8"</p>
<p class="PropText">Case Is > 8 And iVar < 11</p>
<p class="PropText">Print "Greater than 8"</p>
<p class="PropText">Case Else</p>
<p class="PropText">Print "Outside range 1 to 10"</p>